home *** CD-ROM | disk | FTP | other *** search
/ Hershey's Sega Sampler / Hershey's Sega Sampler.iso / garfield / garfield.mst < prev    next >
Text File  |  1996-07-23  |  26KB  |  739 lines

  1. '**************************************************************************
  2. '*                  MS Test script for Garfield Zone setup program
  3. '**************************************************************************
  4.  
  5. '' $DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST WELCOME                  = 100
  12. CONST ASKQUIT                  = 200
  13. CONST DESTPATH                 = 300
  14. CONST EXITFAILURE              = 400
  15. CONST EXITQUIT                 = 600
  16. CONST EXITSUCCESS              = 700
  17. CONST OPTIONS                  = 800
  18. CONST BADPATH                  = 6400
  19.  
  20. CONST HELPWELCOME              = 1000
  21. CONST VERPATH                  = 1100
  22. CONST EXITFAILNOTWIN31         = 1200
  23. CONST EXITFAILNOTENH           = 1300
  24. CONST EXITFAILNOTPAGING        = 1325
  25. CONST EXITFAILNOTINTEL         = 1350
  26. CONST EXITFAILRUNAPP           = 1360
  27. CONST GARFIELDINST             = 1400
  28. CONST GARFIELDINSTNOWIN32S     = 1450
  29. CONST GARFIELDPATH             = 1500
  30. CONST HELPGARFIELD             = 1600
  31.  
  32.  
  33. ''Bitmap ID
  34. CONST LOGO = 1
  35.  
  36. ''GetTempFileName flags
  37. CONST TF_FORCEDRIVE            = 128
  38.  
  39. GLOBAL DESTWIN$      ''Windows directory.
  40. GLOBAL DESTSYS$      ''Windows\System directory.
  41. GLOBAL DEST32S$      ''Windows\System\Win32s directory
  42. GLOBAL DESTGARFIELD$     ''Garfield directory
  43. GLOBAL OLE_PROTECT%  ''Indicates whether ole2 dlls were protected from being
  44.                      '' copied.
  45. GLOBAL OLE_OLEBOOT%
  46. GLOBAL VERNUM$       '' Win32s Version Number (i.e., for v1.25 VERNUM$="125"
  47.  
  48. DECLARE SUB Install(OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%)
  49. DECLARE SUB RecoverFromCopy(szFileName$)
  50. DECLARE SUB UpdateSystemIni
  51. DECLARE FUNCTION RebootSystem(OLEONLY%) AS INTEGER
  52. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  53. DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$) AS INTEGER
  54. DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER
  55. DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER
  56. DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER
  57. DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER
  58. DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER
  59. DECLARE FUNCTION IsRunningApp LIB "INIUPD.DLL" AS INTEGER
  60. DECLARE FUNCTION SetCuiFlags LIB "MSCUISTF.DLL" (arg1%, arg2%) AS INTEGER
  61. DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER
  62. DECLARE FUNCTION GetModuleHandle LIB "KRNL386.EXE" (arg1$) AS INTEGER
  63. DECLARE FUNCTION LoadLibrary LIB "KRNL386.EXE" (arg1$) AS INTEGER
  64. DECLARE SUB FreeLibrary LIB "KRNL386.EXE" (arg1%)
  65. DECLARE FUNCTION SetErrorMode LIB "KRNL386.EXE" (arg1%) AS INTEGER
  66.  
  67. DECLARE FUNCTION GetTempFileName LIB "KRNL386.EXE" (drive%, prefix$, u%, filename$) AS INTEGER
  68. DECLARE SUB WriteLine LIB "INIUPD.DLL" (filename$, text$)
  69. DECLARE FUNCTION GetTempFileAt(szDir$, szPrefix$) as string
  70. INIT:
  71.     CUIDLL$ = "mscuistf.dll"            '' Custom user interface dll
  72.     HELPPROC$ = "FHelpDlgProc"          '' Help dialog procedure
  73.     szOldVer$ ="1.00.000     "          '' Reserve space in string for version
  74.     WIN32ENABLED% = 0
  75.     OLEONLY% = 0
  76.     OLE2_16% = 0
  77.     OLE2AUTO_16% = 0
  78.     OLE16RUNAPP% = 0
  79.     OLE_PROTECT% = 0
  80.     OLE_OLEBOOT% = 0
  81.     SetRestartDir GetWindowsDir()
  82.     ON ERROR GOTO ERRNORMAL
  83.  
  84.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  85.  
  86.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  87.     IF szInf$ = "" THEN
  88.         szInf$ = GetSymbolValue("STF_CWDDIR") + "garfield.inf"
  89.     END IF
  90.     ReadInfFile szInf$
  91.  
  92.     SetBitmap CUIDLL$, LOGO
  93.  
  94.     WIN32SVER$ = MID$(GetSectionKeyVersion("WindowsSystem", "win32s16"), 1, 4)
  95. '    SetTitle "Microsoft Win32s version " + WIN32SVER$ + " Setup Program"
  96.     VERNUM$ = MID$(WIN32SVER$, 1, 1) + MID$(WIN32SVER$, 3 , 2)
  97.  
  98.     DESTWIN$ = GetWindowsDir()
  99.     DESTSYS$ = GetWindowsSysDir()
  100.     DEST32S$ = DESTSYS + "WIN32S\"
  101.  
  102. '$IFDEF DEBUG
  103.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  104.     WinDrive$ = MID$(GetWindowsDir, 1, 1)
  105.     IF IsDriveValid(WinDrive$) = 0 THEN
  106.         i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  107.         GOTO QUIT
  108.     END IF
  109. '$ENDIF ''DEBUG
  110.  
  111. CHECK:
  112.     '' Can not run on versions less than 3.10.
  113.     WINDOWSVERSION = GetWindowsMajorVersion * 100 + GetWindowsMinorVersion
  114.     IF WINDOWSVERSION < 310 THEN
  115.         ExitCode% = EXITFAILNOTWIN31
  116.         GOTO QUIT
  117.     END IF
  118.     '' Check that we are not runnig on Chicago, including pre-released
  119.     '' Chicago versions.
  120.     IF WINDOWSVERSION > 350 THEN
  121.         ExitCode% = EXITSUCCESS
  122.         WIN32ENABLED% = 1
  123.         GOTO GARFIELD
  124.     END IF
  125.     IF GetWindowsMode < 2  THEN
  126.         IF OnWindowsNT() THEN
  127.             ExitCode% = EXITFAILNOTINTEL '' Running on Windows NT (on RISC)
  128.         ELSE
  129.             ExitCode% = EXITFAILNOTENH   '' Standard Mode Windows
  130.         END IF
  131.         GOTO QUIT
  132.     END IF
  133.     IF OnWindowsNT() THEN
  134.         ExitCode% = EXITSUCCESS
  135.         WIN32ENABLED% = 1
  136.         GOTO GARFIELD
  137.     END IF
  138.     ExitCode% = EXITSUCCESS
  139.  
  140.     if IsRunningApp() <> 0 THEN
  141.         ExitCode% = EXITFAILRUNAPP
  142.         GOTO QUIT
  143.     END IF
  144.  
  145.     '' Get version of Win32s to be installed from version info in INF file
  146.     szNewVer$ = GetSectionKeyVersion("WindowsSystem", "win32s16")
  147.  
  148.     '' See if OLE is included.
  149.  
  150.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "OLE2THK.DL_", femExists )
  151.  
  152.     IF OLEINCLUDED% = 1 THEN
  153.         '' See whether one of the OLE 16 bit components is loaded.
  154.         IF GetModulehandle("compobj") <> 0 THEN
  155.             OLE16RUNAPP% = 1
  156.             GOTO GetOleVersion
  157.         END IF
  158.         IF GetModuleHandle("ole2") <> 0 THEN
  159.             OLE16RUNAPP% = 1
  160.             GOTO GetOleVersion
  161.         END IF
  162.         IF GetModuleHandle("ole2prox") <> 0 THEN
  163.             OLE16RUNAPP% = 1
  164.             GOTO GetOleVersion
  165.         END IF
  166.         IF GetModuleHandle("ole2conv") <> 0 THEN
  167.             OLE16RUNAPP% = 1
  168.             GOTO GetOleVersion
  169.         END IF
  170.         IF GetModuleHandle("storage") <> 0 THEN
  171.             OLE16RUNAPP% = 1
  172.             GOTO GetOleVersion
  173.         END IF
  174.         IF GetModuleHandle("ole2nls") <> 0 THEN
  175.             OLE16RUNAPP% = 1
  176.             GOTO GetOleVersion
  177.         END IF
  178.         IF GetModuleHandle("ole2disp") <> 0 THEN
  179.             OLE16RUNAPP% = 1
  180.             GOTO GetOleVersion
  181.         END IF
  182.         IF GetModuleHandle("typelib") <> 0 THEN
  183.             OLE16RUNAPP% = 1
  184.             GOTO GetOleVersion
  185.         END IF
  186.  
  187. GetOleVersion:
  188.         szOleNewVer$ = GetSectionKeyVersion("OleWindowsSystemWin32s", "ole2thk")
  189.  
  190.         '' Get version of currently installed OLE32 from version info of
  191.         '' ole2thk file
  192.         szOleOldVer$ = GetVersionOfFile( DESTSYS$ + "WIN32S\OLE2THK.DLL" )
  193.  
  194.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "COMPOBJ.DLL" )
  195.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "compobj")
  196.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  197.             OLE2_16% = 1
  198.         END IF
  199.  
  200.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2.DLL" )
  201.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2")
  202.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  203.             OLE2_16% = 1
  204.         END IF
  205.  
  206.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2PROX.DLL" )
  207.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2prox")
  208.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  209.             OLE2_16% = 1
  210.         END IF
  211.  
  212.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "STORAGE.DLL" )
  213.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "storage")
  214.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  215.             OLE2_16% = 1
  216.         END IF
  217.  
  218.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2CONV.DLL" )
  219.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2conv")
  220.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  221.             OLE2_16% = 1
  222.         END IF
  223.  
  224.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2NLS.DLL" )
  225.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2nls")
  226.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  227.             OLE2AUTO_16% = 1
  228.         END IF
  229.  
  230.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "OLE2DISP.DLL" )
  231.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "ole2disp")
  232.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  233.             OLE2AUTO_16% = 1
  234.         END IF
  235.  
  236.         szOle16OldVer$ = GetVersionOfFile( DESTSYS$ + "TYPELIB.DLL" )
  237.         szOle16NewVer$ = GetSectionKeyVersion("OleWindowsSystem", "typelib")
  238.         IF (szOle16NewVer$ > szOle16OldVer$) THEN
  239.             OLE2AUTO_16% = 1
  240.         END IF
  241.  
  242.     END IF
  243.  
  244.     OLE2_32% = OLEINCLUDED%
  245.  
  246.     '' Check if Win32s is partially installed
  247.     sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup")
  248.     '' If WIN32S.INI specifies Win32s Setup=0, then force complete Win32s file overwrite
  249.     IF sz$ = "0" THEN
  250.         GOTO WELCOME
  251.     END IF
  252.     '' If WIN32S.INI is missing, try and reinstall Win32s files/recreate WIN32S.INI
  253.     IF sz$ <> "1" THEN
  254.         GOTO WELCOME
  255.     END IF
  256.  
  257.     '' If Win32s is already installed, get running version number
  258.     i% = DoesFileExist( DESTSYS$ + "W32SYS.DLL", femExists )
  259.     IF i% = 1 THEN
  260.         i% = IsWin32sLoaded( szOldVer$ )
  261.     ENDIF
  262.  
  263.     IF i% = 0 THEN
  264.         GOTO WELCOME
  265.     END IF
  266.  
  267.     IF szNewVer$ > szOldVer$ THEN
  268.         GOTO WELCOME
  269.     END IF
  270.  
  271.     IF OLEINCLUDED% = 1 THEN
  272.  
  273.         OLE2_32% = 0
  274.  
  275.         IF (szNewVer$ = szOldVer$) OR (szNewVer$ < szOldVer$) THEN
  276.             '' Compare OLE32 version and versions of each of OLE16 libraries.
  277.             sz$ = GetIniKeyString (DESTSYS$ + "WIN32S.INI", "OLE", "Setup")
  278.             '' If WIN32S.INI specifies OLE2 Setup=0, then force OLE2 file overwrite
  279.             IF ((sz$ <> "1") OR (szOleNewVer$ > szOleOldVer$)) THEN
  280.                 OLEONLY% = 1
  281.                 OLE2_32% = 1
  282.                 GOTO WELCOME
  283.             END IF
  284.  
  285.             IF OLE2_16% OR OLE2AUTO_16 THEN
  286.                 OLEONLY% = 1
  287.                 GOTO WELCOME
  288.             END IF
  289.  
  290.         END IF
  291.  
  292.     END IF
  293.  
  294.     WIN32ENABLED% = 1
  295.     GOTO GARFIELD
  296.  
  297. WELCOME:
  298.     i% = SetCuiFlags(OLEONLY%, OLE16RUNAPP%)
  299.     sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", HELPWELCOME, HELPPROC$)
  300.     IF sz$ = "CONTINUE" THEN
  301.         UIPop 1
  302.     ELSE
  303.         UIPop 1
  304.         GOSUB ASKQUIT
  305.         GOTO WELCOME
  306.     END IF
  307.  
  308.  
  309. GETWIN32SPATH:
  310.     IF PagingEnabled() = 0 THEN
  311.         i% = DoMsgBox("Use the Control Panel 386 Enhanced icon and configure Windows using the Virtual Memory option.", "Win32s requires Virtual Memory", MB_TASKMODAL+MB_ICONHAND+MB_OK)
  312.         ExitCode% = EXITFAILURE '' Enhanced mode but not paging
  313.         GOTO QUIT
  314.     END IF
  315.  
  316.     IF ShareEnabled() = 0 THEN
  317.         i% = DoMsgBox( "File-sharing must be enabled. Run SHARE.EXE before starting Windows or add SHARE.EXE to your AUTOEXEC.BAT file.", "Win32s Setup: SHARE.EXE is not loaded", MB_TASKMODAL+MB_ICONEXCLAMATION+MB_OK)
  318.     END IF
  319.  
  320.     SetSymbolValue "EditTextIn", DESTSYS$
  321.     SetSymbolValue "EditFocus", "END"
  322.  
  323. GETPATHL1:
  324.     sz$ = UIStartDlg(CUIDLL$, VERPATH, "FDispDlgProc", HELPWELCOME, HELPPROC$)
  325.  
  326.     IF sz$ = "CONTINUE" THEN
  327.         IF IsDirWritable(DESTSYS$) = 0 THEN
  328.             GOSUB BADPATH
  329.             GOTO GETPATHL1
  330.         END IF
  331.         UIPop 1
  332.     ELSEIF sz$ = "REACTIVATE" THEN
  333.         UIPop 1
  334.         GOTO GETPATHL1
  335.     ELSEIF sz$ = "BACK" THEN
  336.         UIPop 1
  337.         GOTO WELCOME
  338.     ELSE
  339.         UIPop 1
  340.         GOSUB ASKQUIT
  341.         GOTO GETPATHL1
  342.     END IF
  343.  
  344. COPYFILES:
  345.     IF OLEONLY% = 0 THEN
  346.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  347.     END IF
  348.     IF OLE2_32% = 1 THEN
  349.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "0", cmoOverwrite
  350.     END IF
  351.  
  352.     '' Indicate Win32s install failure until all files known to be copied.
  353.     ExitCode% = EXITFAILURE
  354.     ERR = 0
  355.     CreateDir DEST32S$, cmoNone
  356.     Install OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%
  357.     UpdateSystemIni
  358.     '' Terminate if unhandled fatal error
  359.     IF ERR <> 0 THEN
  360.     GOTO QUIT
  361.     END IF
  362.  
  363.     IF OLEONLY% = 0 THEN
  364.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite
  365.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite
  366.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite
  367.     END IF
  368.     IF OLE2_32% = 1 THEN
  369.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "1", cmoOverwrite
  370.         CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Version", szOleNewVer, cmoOverwrite
  371.     END IF
  372.  
  373.     i% = DoMsgBox("Win32s files successfully installed.", "Microsoft Win32s Setup", MB_OK+MB_TASKMODAL)
  374.     '' Indicate Win32s correctly copied and installed.
  375.     ExitCode% = EXITSUCCESS
  376.  
  377. GARFIELD:
  378.     IF OLEONLY% = 1 THEN
  379.         GOTO QUIT
  380.     ENDIF
  381.     IF WIN32ENABLED% = 0 THEN
  382.         sz$ = UIStartDlg(CUIDLL$, GARFIELDINST, "FInfoDlgProc",0, "")
  383.         UIPop 1
  384.         IF sz$ <> "CONTINUE" THEN
  385.             GOTO QUIT
  386.         END IF
  387.     END IF
  388.  
  389. GETGARFIELDPATH:
  390.     DESTGARFIELD$ = "C:\SEGA\GAR_DEMO\"
  391.     SetSymbolValue "EditTextIn", DESTGARFIELD$
  392.     SetSymbolValue "EditFocus", "END"
  393.  
  394. GETGARFIELDPATHL1:
  395.     sz$ = UIStartDlg(CUIDLL$, GARFIELDPATH, "FEditDlgProc", HELPGARFIELD, HELPPROC$)
  396.  
  397.     IF sz$ = "CONTINUE" THEN
  398.         DESTGARFIELD$ = GetSymbolValue("EditTextOut")
  399.  
  400.         IF MID$(DESTGARFIELD$, LEN(DESTGARFIELD$), 1) <> "\" THEN
  401.             DESTGARFIELD$ = DESTGARFIELD$ + "\"
  402.         END IF
  403.         ''Validate new path.
  404.         IF IsDirWritable(DESTGARFIELD$) = 0 THEN
  405.             GOSUB BADPATH
  406.             GOTO GETGARFIELDPATHL1
  407.         END IF
  408.         UIPop 1
  409.  
  410.         GOTO COPYGARFIELD
  411.     ELSEIF sz$ = "REACTIVATE" THEN
  412.         GOTO GETGARFIELDPATHL1
  413.     ELSEIF sz$ = "EXIT" THEN
  414.         UIPop 1
  415.         GOTO QUIT
  416.     END IF
  417.  
  418. COPYGARFIELD:
  419.     ClearCopyList
  420.     CreateDir DESTGARFIELD$, cmoNone
  421.  
  422.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  423.  
  424.     ERR = 0
  425.     AddSectionFilesToCopyList "Garfield", SrcDir$, DESTGARFIELD$
  426.     IF WINDOWSVERSION > 350 THEN
  427.         AddSectionFilesToCopyList "Garfield32", SrcDir$, DESTGARFIELD$
  428.     ELSE
  429.         AddSectionFilesToCopyList "Garfield16", SrcDir$, DESTGARFIELD$
  430.     END IF
  431.     AddSectionFilesToCopyList "Garfield System", SrcDir$, DESTSYS$
  432.     CopyFilesInCopyList
  433.     '' If error copying Garfield, not a fatal error. Win32s is already installed.
  434.     IF ERR <> 0 THEN
  435.     ERR = 0
  436.     GOTO QUIT
  437.     END IF
  438.     ERR = 0
  439.  
  440.     IF DoesFileExist( DESTSYS$ + "WIN32S.INI", femExists ) THEN
  441.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Garfield", "Setup", "1", cmoOverwrite
  442.     CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Garfield", "Version", szNewVer$, cmoOverwrite
  443.     END IF
  444.  
  445.     ERR = 0
  446.     CreateProgmanGroup "SEGA PC", "", cmoNone
  447.     ShowProgmanGroup   "SEGA PC", 1, cmoNone
  448.     CreateProgmanItem  "SEGA PC", "Garfield", DESTGARFIELD$ + "GARFIELD.EXE", "", cmoOverwrite
  449.     '' Only put up success dialog if icon added to group
  450.     IF ERR = 0 THEN
  451.     i% = DoMsgBox("Garfield was successfully installed.", "Garfield Setup", MB_OK+MB_TASKMODAL)
  452.     CreateIniKeyValue "WIN.INI", "Garfield", "path", DESTGARFIELD$, cmoOverwrite
  453.     CreateIniKeyValue "WIN.INI", "Garfield", "files", SrcDir$, cmoOverwrite
  454.     END IF
  455.     ERR = 0
  456.  
  457. QUIT:
  458.     '' Install error handler for final message box routines
  459.     ON ERROR GOTO ERRQUIT
  460.     IF ERR = 0 THEN
  461.         dlg% = ExitCode%
  462.     ELSEIF ERR = STFQUIT THEN
  463.         IF (OLE_PROTECT% = 1) THEN
  464.             '' Free all previously loaded libraries
  465.             FreeLibrary GetModuleHandle("compobj")
  466.             FreeLibrary GetModuleHandle("ole2")
  467.             FreeLibrary GetModuleHandle("ole2prox")
  468.             FreeLibrary GetModuleHandle("ole2conv")
  469.             FreeLibrary GetModuleHandle("storage")
  470.             FreeLibrary GetModuleHandle("ole2nls")
  471.             FreeLibrary GetModuleHandle("ole2disp")
  472.             FreeLibrary GetModuleHandle("typelib")
  473.         END IF
  474.         dlg% = EXITQUIT
  475.         ExitCode% = EXITQUIT
  476.     ELSE
  477.         dlg% = EXITFAILURE
  478.         ExitCode% = EXITQUIT
  479.     END IF
  480.  
  481. QUITL1:
  482.     IF WIN32ENABLED% = 1 THEN
  483.         UIPop 1
  484.         END
  485.     END IF
  486.  
  487.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  488.     IF sz$ = "REACTIVATE" THEN
  489.         GOTO QUITL1
  490.     END IF
  491.     UIPop 1
  492.  
  493.     IF ExitCode% = EXITSUCCESS THEN
  494.         IF RebootSystem(OLEONLY% and not OLE_OLEBOOT%) = 0 THEN
  495.             CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite
  496.             IF OLE2_32% = 1 THEN
  497.                 CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "OLE", "Setup", "0", cmoOverwrite
  498.             END IF
  499.             i% = DoMsgBox("Win32s is not properly configured and Win32s Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL)
  500.         END IF
  501.     ENDIF
  502.  
  503.     END
  504.  
  505. '' Fatal error handler for error message routine
  506. ERRQUIT:
  507.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  508.     END
  509.  
  510. '' Bypass run-time errors. Let final dialog box display fatal error message.
  511. ERRNORMAL:
  512.     '' Check if user cancelled setup
  513.     IF ERR = STFQUIT THEN
  514.     GOTO QUIT
  515.     END IF
  516.     RESUME NEXT
  517.  
  518.  
  519. BADPATH:
  520.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  521.     IF sz$ = "REACTIVATE" THEN
  522.         GOTO BADPATH
  523.     END IF
  524.         UIPop 1
  525.     RETURN
  526.  
  527.   ASKQUIT:
  528.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  529.  
  530.     IF sz$ = "EXIT" THEN
  531.         UIPop 1
  532.         UIPopAll
  533.         ERROR STFQUIT
  534.     ELSEIF sz$ = "REACTIVATE" THEN
  535.         GOTO ASKQUIT
  536.     ELSE
  537.         UIPop 1
  538.     END IF
  539.     RETURN
  540.  
  541.  
  542.  
  543. '**
  544. '** Purpose:
  545. '**     Builds the copy list and performs all installation operations.
  546. '** Arguments:
  547. '**     none.
  548. '** Returns:
  549. '**     none.
  550. '*************************************************************************
  551. SUB Install(OLEONLY%, OLE2_32%, OLE2_16%, OLE2AUTO_16%, OLE16RUNAPP%) STATIC
  552.  
  553.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  554.  
  555.     '' Use file layout sections that specify OLDER file version/time check
  556.     IF OLEONLY% = 0 THEN
  557.         AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$
  558.         AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  559.         '' Add obsolete files to be removed
  560.         AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, DESTSYS$ + "WIN32S\"
  561.     END IF
  562.  
  563.     OLE_PROTECT% = 0
  564.     OLEINCLUDED% = DoesFileExist( GetSymbolValue("STF_SRCDIR") + "OLE2THK.DL_", femExists )
  565.     if OLEINCLUDED% = 1 THEN
  566.         IF (OLE2_16% = 1) OR (OLE2AUTO_16% = 1) THEN
  567.             IF OLE16RUNAPP% = 1 THEN
  568.                 '' Force all OLE2 DLLS to be copied during reboot.
  569.                 i% = SetErrorMode(-32768)
  570.                 i% = LoadLibrary(DESTSYS$ + "compobj.dll")
  571.                 i% = LoadLibrary(DESTSYS$ + "ole2.dll")
  572.                 i% = LoadLibrary(DESTSYS$ + "ole2prox.dll")
  573.                 i% = LoadLibrary(DESTSYS$ + "ole2conv.dll")
  574.                 i% = LoadLibrary(DESTSYS$ + "storage.dll")
  575.                 i% = LoadLibrary(DESTSYS$ + "ole2nls.dll")
  576.                 i% = LoadLibrary(DESTSYS$ + "ole2disp.dll")
  577.                 i% = LoadLibrary(DESTSYS$ + "typelib.dll")
  578.                 OLE_PROTECT% = 1
  579.             END IF
  580.             AddSectionFilesToCopyList "OleWindowsSystem", SrcDir$, DESTSYS$
  581.         END IF
  582.         IF OLE2_32% = 1 THEN
  583.             AddSectionFilesToCopyList "OleWindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\"
  584.         END IF
  585.         IF (OLE2_16% = 1) OR (OLE2_32% = 1) OR (OLE2AUTO_16% = 1) THEN
  586.             AddSectionFilesToCopyList "Ole2RegWindowsSystem", SrcDir$, DESTSYS$
  587.         END IF
  588.         IF (OLE2AUTO_16% = 1) THEN
  589.             AddSectionFilesToCopyList "StdoleWindowsSystem", SrcDir$, DESTSYS$
  590.             IF (OLE16RUNAPP and DoesFileExist(DESTSYS$ + "stdole.tlb", femExists) ) THEN
  591.                 ' copy stdole.tlb -> tempfile1
  592.                 stdole1$ = DESTSYS$ + GetTempFileAt(DESTSYS$, "STD")
  593.                 CopyFile DESTSYS$+"STDOLE.TLB", stdole1$, cmoOverwrit, 0
  594.                 OLE_OLEBOOT% = 1
  595.             ENDIF
  596.         END IF
  597.     END IF
  598.  
  599.  
  600.  
  601.     CopyFilesInCopyList
  602.  
  603.     IF (OLEINCLUDED% = 1) THEN
  604.         RecoverFromCopy DESTSYS$ + "compobj.dll"
  605.         RecoverFromCopy DESTSYS$ + "ole2.dll"
  606.         RecoverFromCopy DESTSYS$ + "ole2prox.dll"
  607.         RecoverFromCopy DESTSYS$ + "ole2conv.dll"
  608.         RecoverFromCopy DESTSYS$ + "storage.dll"
  609.         RecoverFromCopy DESTSYS$ + "ole2nls.dll"
  610.         RecoverFromCopy DESTSYS$ + "ole2disp.dll"
  611.         RecoverFromCopy DESTSYS$ + "typelib.dll"
  612.     END IF
  613.  
  614.     IF (OLE_PROTECT% = 1) THEN
  615.         '' Free all previously loaded libraries
  616.         FreeLibrary GetModuleHandle("compobj")
  617.         FreeLibrary GetModuleHandle("ole2")
  618.         FreeLibrary GetModuleHandle("ole2prox")
  619.         FreeLibrary GetModuleHandle("ole2conv")
  620.         FreeLibrary GetModuleHandle("storage")
  621.         FreeLibrary GetModuleHandle("ole2nls")
  622.         FreeLibrary GetModuleHandle("ole2disp")
  623.         FreeLibrary GetModuleHandle("typelib")
  624.         OLE_PROTECT% = 0
  625.     END IF
  626.     IF (OLE_OLEBOOT% = 1) THEN
  627.             'rename new stdole.tlb -> tempfile2
  628.             stdole2$ = GetTempFileAt(DESTSYS$, "STD")
  629.             RemoveFile DESTSYS$+stdole2$, cmoForce
  630.             RenameFile DESTSYS$+"STDOLE.TLB" , stdole2$
  631.             'rename tempfile1 -> stdole.tlb
  632.             RenameFile stdole1$, "STDOLE.TLB"
  633.             'write to _mssetup.bat: rename tempfile2 to stdole.tlb
  634.             WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  635.             WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTSYS$+"STDOLE.TLB"
  636.             WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTSYS$+stdole2$+" STDOLE.TLB"
  637.     ENDIF
  638.     IF OLEINCLUDED% AND (OLE2_16% OR OLE2_32% OR OLE2AUTO_16%) THEN
  639.         IF OLE16RUNAPP% THEN
  640.             reg1$ = DESTWIN$ + GetTempFileAt(DESTWIN$, "REG")
  641.             CopyFile DESTWIN$+"REG.DAT", reg1$, cmoOverwrit, 0
  642.         ENDIF
  643.  
  644.         RUN "regedit /s " + DESTSYS$ + "ole2.reg"
  645.  
  646.         IF OLE16RUNAPP% THEN
  647.             reg2$ = GetTempFileAt(DESTWIN$, "REG")
  648.             RemoveFile DESTWIN$ + reg2$, cmoForce
  649.             RenameFile DESTWIN$ + "REG.DAT" , reg2$
  650.             'rename tempfile1 -> reg.dat
  651.             RenameFile reg1$, "REG.DAT"
  652.             'write to _mssetup.bat: rename tempfile2 to reg.dat
  653.             WriteLine DESTWIN$+"_MSSETUP.BAT", ""
  654.             WriteLine DESTWIN$+"_MSSETUP.BAT", "DEL "+DESTWIN$+"REG.DAT"
  655.             WriteLine DESTWIN$+"_MSSETUP.BAT", "REN "+DESTWIN$ + reg2$+" REG.DAT"
  656.             OLE_OLEBOOT% = 1
  657.         ENDIF
  658.     END IF
  659. END SUB
  660.  
  661. SUB UpdateSystemIni STATIC
  662.  
  663.     VxDPath$ = DEST32S$ + "W32S.386"
  664.     SystemIniPath$ = GetWindowsDir()
  665.  
  666.     t% = MakeSystemIni(SystemIniPath$, VxdPath$)
  667.  
  668. END SUB
  669.  
  670. FUNCTION RebootSystem(OLEONLY%) STATIC AS INTEGER
  671.  
  672. '   Check if any files were locked during install.  If the RestartList
  673. '   is not empty, ExitExecRestart() will restart Windows, cleanup setup
  674. '   files, and copy over locked files before Windows restarts.
  675.     i% = RestartListEmpty()
  676.     IF i% = 0 THEN
  677. '      ExitExecRestart() only returns if applications refuse to be shutdown.
  678. '      Win32s is installed but will not operate until Windows is restarted
  679. '      and the Win32s VxD is loaded.
  680.        i% = ExitExecRestart()
  681.        RebootSystem = 0
  682.     ELSE
  683. '      If the RestartList list is empty, it is necessary to restart windows
  684. '      directly.  The MSSETUP program creates _MSRSTRT.EXE and _MSSETUP.BAT
  685. '      in the restart directory.  This program should be exec'd to handle
  686. '      proper MSSETUP cleanup (temp files) and restart Windows.
  687.        IF (OLEONLY% = 1) THEN
  688.            RebootSystem = 1
  689.        ELSE
  690.            i% = ExitWindowsExec( GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT" )
  691.            RebootSystem = 0
  692.        END IF
  693.     ENDIF
  694.  
  695. END FUNCTION
  696.  
  697.  
  698. '**
  699. '** Purpose:
  700. '**     Appends a file name to the end of a directory path,
  701. '**     inserting a backslash character as needed.
  702. '** Arguments:
  703. '**     szDir$  - full directory path (with optional ending "\")
  704. '**     szFile$ - filename to append to directory
  705. '** Returns:
  706. '**     Resulting fully qualified path name.
  707. '*************************************************************************
  708. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  709.     IF szDir$ = "" THEN
  710.     MakePath = szFile$
  711.     ELSEIF szFile$ = "" THEN
  712.     MakePath = szDir$
  713.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  714.     MakePath = szDir$ + szFile$
  715.     ELSE
  716.     MakePath = szDir$ + "\" + szFile$
  717.     END IF
  718. END FUNCTION
  719.  
  720. FUNCTION GetTempFileAt(szDir$, szPrefix$) STATIC AS STRING
  721.     szCurDir$ = CURDIR$
  722.     CHDIR szDir$ + "."
  723.     szTempFile$ = STRING$(144, "E")
  724.     i% = GetTempFileName(TF_FORCEDRIVE, szPrefix$,0, szTempFile$)
  725.     CHDIR szCurDir$
  726.     GetTempFileAt = MID$(szTempFile$,3)
  727. END FUNCTION
  728.  
  729. SUB RecoverFromCopy(szFileName$) STATIC
  730.     IF DoesFileExist(szFileName$, femExist) = 0 THEN
  731.         szBackFile$ = MID$(szFileName$, 1, LEN(szFileName$)-3) + VERNUM$
  732.         IF DoesfileExist(szBackFile$, femExist) = 0 THEN
  733.             i% = DoMsgBox("ERROR: Could not find backup file "+szBackfile$, "Setup Error", MB_ICONEXLAMATION + MB_OK)
  734.         ELSE
  735.             CopyFile szBackFile$, szFileName$, cmoTimeStamp, 0
  736.         END IF
  737.     END IF
  738. END SUB
  739.